//
//  URLAddress.m
//  NewsReader
//
//  Created by blacksun on 10-10-18.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "URLAddress.h"
#import "NewsReaderAppDelegate.h"
#import "User.h"

//static NSString *baseUrl = @"http://ipoint-userface.appspot.com";
//static NSString *spareUrl = @"http://userface.ipoint.mobi";
//static NSString *baseUrl = @"http://userface.ipoint.mobi";//首选服务器
static NSString *baseUrl = @"http://api.ipointstyle.com";
//static NSString *spareUrl = @"http://userface.ipointstyle.com";//备用服务器
@implementation URLAddress

+(NSString *) returnBaseUrl{
	return baseUrl;
} 

+ (NSString *) getUrl{
	return baseUrl;
	/*NewsReaderAppDelegate *delegate = (NewsReaderAppDelegate *)[UIApplication sharedApplication].delegate;
	if (delegate.isGFW) {
		//NSLog(@"%@",spareUrl);
		return spareUrl;

	}
	//NSLog(@"%@",baseUrl);
	return baseUrl;*/
}


+ (NSString *) anonymousRegister:(NSString *)deviceId {
	NSString *url =  [[[NSString alloc] initWithFormat:@"%@%@%@&os=%@&sv=%@",[URLAddress getUrl],@"/user/anonymous?d=",deviceId,@"iOS",@"0.8"] autorelease];	
	//NSLog(@"%@",url);
	return url;
}
+ (NSString *) listAllSections{
	NSString *url =   [[[NSString alloc] initWithFormat:@"%@%@",[URLAddress getUrl],@"/cached/section/nested"] autorelease];
	//NSLog(@"%@",url);
	return url;
}
+ (NSString *) getMySections:(NSString * )sectionIds forMe:(NSString * )userid{
	NSString *url =   [[[NSString alloc] initWithFormat:@"%@/section/query?u=%@&s=%@",[URLAddress getUrl],userid,sectionIds] autorelease];
	//NSLog(@"%@",url);
	return url;
}
+ (NSString *) addSections:(NSString *)sectionIds forMe:(NSString * )userid{

	NSString *url =   [[[NSString alloc] initWithFormat:@"%@/section/subscribe?u=%@&s=%@",[URLAddress getUrl],userid,sectionIds] autorelease];
	//NSLog(@"%@",url);
	return url;
}
+ (NSString *) deleteMySections:(NSString *)sectionIds forMe:(NSString * )userId{
	NSString *url =   [[[NSString alloc] initWithFormat:@"%@/section/unsubscribe?u=%@&s=%@",[URLAddress getUrl],userId,sectionIds] autorelease];
	//NSLog(@"%@",url);
	return url;
}
+ (NSString *) listFeedsWithSection:(NSString * )sectionId maxId:(NSInteger)maxId{
	NewsReaderAppDelegate *delegate = (NewsReaderAppDelegate *)[UIApplication sharedApplication].delegate;
	NSInteger count = delegate.user.feedSizePerRequest;
	NSString *url =   [[[NSString alloc] initWithFormat:@"%@/feed/newest?s=%@&m=%d&c=%d&u=%@",[URLAddress getUrl],sectionId,maxId,count,delegate.user.userId] autorelease];
	//NSLog(@"%@",url);
	return url;
}

+ (NSString *) lastFeedsWithSection:(NSString * )sectionId{
	NewsReaderAppDelegate *delegate = (NewsReaderAppDelegate *)[UIApplication sharedApplication].delegate;
	NSInteger count = delegate.user.feedSizePerRequest;
	NSString *url =   [[[NSString alloc] initWithFormat:@"%@/feed/last?s=%@&c=%d&u=%@",[URLAddress getUrl],sectionId,count,delegate.user.userId] autorelease];
	//NSLog(@"%@",url);
	return url;
}

+ (NSString *)loadOlderFeedsWithSection:(NSString *)sectionId currentMinId:(NSInteger)currentMinId{
	NewsReaderAppDelegate *delegate = (NewsReaderAppDelegate *)[UIApplication sharedApplication].delegate;
	NSInteger count = delegate.user.feedSizePerRequest;
	NSString *url =    [[[NSString alloc] initWithFormat:@"%@/cached/feed/query?section=%@&start=%d&count=%d",[URLAddress getUrl],sectionId,currentMinId,count] autorelease]; 
	//NSLog(@"%@",url);
	return url;
}
+ (NSString *)loadOlderFeedsWithSubject:(NSString *)subjectId currentMinId:(NSInteger)currentMinId{
    NewsReaderAppDelegate *delegate = (NewsReaderAppDelegate *)[UIApplication sharedApplication].delegate;
	NSInteger count = delegate.user.feedSizePerRequest;
	NSString *url =    [[[NSString alloc] initWithFormat:@"%@/cached/feed/query?subject=%@&start=%d&count=%d",[URLAddress getUrl],subjectId,currentMinId,count] autorelease]; 
	//NSLog(@"%@",url);
	return url;

}
+ (NSString *) sendTweetUrl:(NSString *)feedId{
    NewsReaderAppDelegate *delegate = (NewsReaderAppDelegate *)[UIApplication sharedApplication].delegate;
	NSString *url =    [[[NSString alloc] initWithFormat:@"%@/user/rt?u=%@&f=%@",[URLAddress getUrl],delegate.user.userId,feedId] autorelease]; 
	//NSLog(@"%@",url);
	return url;

}

@end
